package com.zk.algorithm.string;

import com.zk.algorithm.annotation.Easy;
import com.zk.algorithm.annotation.LeetCodeExplore;

/**
 * @author zk
 */
@Easy
@LeetCodeExplore
public class ReverseString {

    public String reverseString(String s) {
        if (s == null || s.length() == 0) {
            return s;
        }

        char[] charArray = s.toCharArray();

        int start = 0;
        int end = charArray.length - 1;

        while (start < end) {
            char tmp = charArray[start];
            charArray[start] = charArray[end];
            charArray[end] = tmp;

            start++;
            end--;
        }

        return new String(charArray);
    }

}
